#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
"""

from threading import Thread
from zipfile import ZipFile, ZIP_DEFLATED

class AsyncZip(Thread):
    def __init__(self, infile, outfile):
        Thread.__init__(self)
        self.infile = infile
        self.outfile = outfile
    def run(self):
        f = ZipFile(self.outfile, 'w', ZIP_DEFLATED)
        f.write(self.infile)
        f.close()
        print 'Finished background zip of: ', self.infile

###
if __name__=="__main__":
    background = AsyncZip('mydata.txt', 'myarchive.zip')
    background.start()
    print 'The main program continues to run in foreground.'

    background.join()    # Wait for the background task to finish
    print 'Main program waited until background was done.'
